import {Injectable} from "@angular/core";
import {Observable} from "rxjs/Observable";

@Injectable()
export class LocalStorageServiceMock {

    public constructor() {
    }

    /*
    * 初始化库
    * */
    public initialize(dbName: string) {
    }

    /*
    * 获取所有储存的数据
    * */
    public getAllData(): Observable<any> {
        return this.getAllDataResult;
    }

    public getAllDataResult: Observable<any>;

    /*
    * 插入数据
    * 插入之后会自动生成一个_id和_rev
    * */
    public createData(data: any): Observable<any> {
        return this.createDataResult;
    }

    public createDataResult: Observable<any>;

    /*
    * 更新修改数据
    * data数据格式：{_id:'',field1:'',field2:''}
    * */
    public updateData(data: any): Observable<any> {
        return this.updateDataResult;
    }

    public updateDataResult: Observable<any>;


    /*
    * 删除数据
    * data数据格式：{_id:'',_rev:''}
    * */
    public deleteData(data: any): Observable<any> {
        return this.deleteDataResult;
    }

    public deleteDataResult: Observable<any>;

    /*
    * 查询数据
    * param数据格式：{
                selector: {name: 'Mario'},
                fields: ['_id', 'name'],
                sort: ['name']
            }
    * */
    public selectData(param: any): Observable<any> {
        return this.selectDataResult;
    }

    public selectDataResult: Observable<any>;

    /*
    * 创建索引
    * param数据格式：{
                index: {
                    fields: ['name','age']
                }
            }
    * */
    public createIndex(param: any): Observable<any> {
        return this.createIndexResult;
    }

    public createIndexResult: Observable<any>;
}
